<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="UTF-8">
    <title>NC端模板自助维护</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../static/struct/layuimini/lib/layui-v2.5.5/css/layui.css " media="all">
    <!--<script type="text/javascript" src="../../static/js/login/jquery.min.js"></script>-->
    <script src="../../../../static/struct/layuimini/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script src="../../../../static/js/generaljs/watermarkbycanvas.js" charset="UTF-8"></script>
    <link rel="stylesheet" href="../../../../static/css/generalcss/layuitablecheckboxfix.css">

</head>
<body onload="addWaterMarker()" style="margin: 10px 10px 10px 10px">
    <form class="layui-form" action="">
        <blockquote class="layui-elem-quote layui-quote-nm">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="product" lay-filter="cpxl">
                                <option value="">直接选择或搜索产品系列</option>
                                <option th:each="pList:${productList}" th:value="${pList}" th:text="${pList}"></option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select name="qybzname" lay-verify="required" lay-search="" id="qybzid" lay-filter="quiz">
                            <option value="">企业标准</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select name="gghname" lay-verify="required" lay-search="" id="gghid" lay-filter="gghfilter">
                            <option value="">规格号</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select name="jglxname" lay-verify="required" lay-search="" id="jglxid" lay-filter="jglxfilter">
                            <option value="">结构类型</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select name="cdlxname" lay-verify="required" lay-search="" id="cdlxid" lay-filter="cdlxfilter">
                            <option value="">触点类型</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn layui-btn"  lay-submit lay-filter="data-search-btn" id="clickToShow"><i class="layui-icon"></i> 抽 样</button>
                    </div>
                    <div class="layui-inline">
                        <button type="button" class="layui-btn layui-btn"  lay-submit lay-filter="data-search-btn" id="transToNc">确认传输</button>
                    </div>
                </div>
            </div>
        </blockquote>
        <hr class="layui-bg-gray">

        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">可能存在的问题</li>
                <li>试验前参数</li>
                <li>试验后参数</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show" id="problemshow">问题清单:<br/></div>
                <div class="layui-tab-item" id="initshowdiv">试验前参数清单:<br/></div>
                <div class="layui-tab-item" id="aftershowdiv">试验后参数清单:<br/></div>
            </div>
        </div>

    </form>
</body>
<script src="../../../../static/struct/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    //watermark({"watermark_txt": initpro()});
    $(document).ready(function(){

    });

    layui.use(['form', 'table','layer','element'], function () {
        let $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layer = layui.layer,
            element = layui.element;

        //产品系列选择后联动
        form.on('select(cpxl)', function(data){
            //console.log(data.value); //得到被选中的产品系列，更新企业标准选项框
            $.ajax({
                url: "/loading/getqybz?param=" + data.value,
                type: 'get',
                contentType: "application/json",
                async:false,
                //data: JSON.stringify({"param": data.value }),
                success: function(result) {
                    if (result.code == 200){
                        $("#qybzid").empty();
                        $("#gghid").empty();
                        $("#jglxid").empty();
                        $("#cdlxid").empty();
                        let obj = result.data;
                        let arr = [];
                        for (let i in obj){
                            arr.push(obj[i]);
                        }
                        for (let j = 0; j < arr.length ; j++){
                            //给企业标准加text和value
                            console.log(arr[j]);
                            //$("#qybzid").append('<option value = "' + arr[j] + '">' + arr[j] + '</option>');
                            $("#qybzid").append(new Option(arr[j], arr[j]));
                            form.render('select');
                        }

                    }else {
                        parent.layer.msg('查询企业标准失败，当前产品系列及版本，没有可用的企标');
                    }
                }
            });
        });



        //企标选择后联动
        form.on('select(quiz)', function(data){
            //定义参数及格式：  产品系列:版本:企标
            let param = $("#product").val() + ':' + data.value;
            $.ajax({
                url: "/loading/getggh?param=" + param,
                type: 'get',
                contentType: "application/json",
                async:false,
                //data: JSON.stringify({"param": data.value }),
                success: function(result) {
                    if (result.code == 200){
                        $("#gghid").empty();
                        $("#jglxid").empty();
                        $("#cdlxid").empty();
                        let obj = result.data;
                        let arr = [];
                        for (let i in obj){
                            arr.push(obj[i]);
                        }
                        for (let j = 0; j < arr.length ; j++){
                            //给企业标准加text和value
                            console.log(arr[j]);
                            //$("#qybzid").append('<option value = "' + arr[j] + '">' + arr[j] + '</option>');
                            $("#gghid").append(new Option(arr[j], arr[j]));
                            form.render('select');
                        }

                    }else {
                        parent.layer.msg('查询规格号失败，当前产品系列及企标下，没有可用的规格号');
                    }
                }
            });
        });


        //规格号选择后联动结构类型(单双稳等)
        form.on('select(gghfilter)', function(data){
            //定义参数及格式：  产品系列:版本:企标
            let param = $("#product").val() + ':' + $("#qybzid").val() + ':' + data.value;
            $.ajax({
                url: "/loading/getjglx?param=" + param,
                type: 'get',
                contentType: "application/json",
                async:false,
                //data: JSON.stringify({"param": data.value }),
                success: function(result) {
                    if (result.code == 200){
                        $("#jglxid").empty();
                        $("#cdlxid").empty();
                        let obj = result.data;
                        let arr = [];
                        for (let i in obj){
                            arr.push(obj[i]);
                        }
                        //$("#jglxid").append(new Option('结构类型', '结构类型'));
                        for (let j = 0; j < arr.length ; j++){
                            //给企业标准加text和value
                            console.log(arr[j]);
                            //$("#qybzid").append('<option value = "' + arr[j] + '">' + arr[j] + '</option>');
                            $("#jglxid").append(new Option(arr[j], arr[j]));
                            form.render('select');
                        }

                    }else {
                        parent.layer.msg('查询结构类型失败，当前产品系列及企标下，没有可用的结构类型');
                    }
                }
            });
        });



        //选择结构类型后，获取触点类型并显示
        form.on('select(jglxfilter)', function(data){
            //定义参数及格式：  产品系列:版本:企标
            let param = $("#product").val() + ':' + $("#qybzid").val() + ':' + $("#gghid").val() + ':' + data.value ;
            $.ajax({
                url: "/loading/getcdlx?param=" + param,
                type: 'get',
                contentType: "application/json",
                async:false,
                //data: JSON.stringify({"param": data.value }),
                success: function(result) {
                    if (result.code == 200){
                        $("#cdlxid").empty();
                        let obj = result.data;
                        let arr = [];
                        for (let i in obj){
                            arr.push(obj[i]);
                        }
                        for (let j = 0; j < arr.length ; j++){
                            //给企业标准加text和value
                            console.log(arr[j]);
                            //$("#qybzid").append('<option value = "' + arr[j] + '">' + arr[j] + '</option>');
                            $("#cdlxid").append(new Option(arr[j], arr[j]));
                            form.render('select');
                        }

                    }else {
                        parent.layer.msg('查询触点类型失败，当前产品系列及企标下，没有可用的触点类型');
                    }
                }
            });
        });


        //确认传输按钮
        $("#transToNc").click(function (){
            //定义参数及格式：  产品系列:版本:企标:规格：结构：触点
            let param = $("#product").val() + ':' + $("#qybzid").val() + ':' + $("#gghid").val() + ':' + $("#jglxid").val() + ':' + $("#cdlxid").val() ;
            var loading = layer.load(2);
            $.ajax({
                url: "/limsaction/translateAnalysis?param=" + param,
                type: 'post',
                contentType: "application/json",
                async:false,
                success: function(result) {
                    if (result.code == 200){
                        parent.layer.msg('方法模板' + $("#product").val()  + '传输成功！');
                        layer.close(loading);
                    }else {
                        layer.close(loading);
                        console.log(result);
                        //let abc = eval("(" + result + ")");
                        //let obj = JSON.stringify(result);
                        parent.layer.alert('传输失败，请按提示修改方法模板：' + result.msg);
                    }
                }
            });
        });


        //抽样按钮点击事件
        $("#clickToShow").click(function () {
            //定义参数及格式：  产品系列:版本:企标:规格：结构：触点
            let param = $("#product").val() + ':' + $("#qybzid").val() + ':' + $("#gghid").val() + ':' + $("#jglxid").val() + ':' + $("#cdlxid").val() ;
            var loading = layer.load(2);
            $.ajax({
                url: "/loading/showAllAction?param=" + param,
                type: 'get',
                contentType: "application/json",
                async:false,
                //data: JSON.stringify({"param": data.value }),
                success: function(result) {
                    if (result.code == 200){
                        //console.log(result.data.init);
                        //$("#initshowdiv")
                        for (let i = 0; i < result.data.problems.length ; i ++){
                            $("#problemshow").append("<p>" + result.data.problems[i] + "</p>" );
                            console.log(result.data.problems[i]);
                        }
                        for (let i = 0; i < result.data.init.length ; i ++){
                            $("#initshowdiv").append("<p>" + result.data.init[i] + "</p>" );
                            console.log(result.data.init[i]);
                        }
                        for (let i = 0; i < result.data.after.length ; i ++){
                            $("#aftershowdiv").append("<p>" + result.data.after[i] + "</p>" );
                            console.log(result.data.after[i]);
                        }
                        layer.close(loading);
                    }else {
                        parent.layer.msg('抽样查询失败，请检查网络');
                        layer.close(loading);
                    }
                }
            });
        });






            /*$("#product").blur(function(){
                //焦点离开产品系列后，更新后面四个框
                $("#product").css("background-color","#D6D6FF");
            });*/


    });

</script>
</html>